<?php
namespace app\admin\controller;
class Upload
{
	public function __construct(){
		Admin_auth();
	}
	
    public function index()
    {
        return view();
    }
	
	public function upload()
    {
		$id = input("get.id")?input("get.id"):0;
		$data = array();
		
		if(request()->isPost()){
			$data = input("post.");
			if(db("user")->where(['phone' => $data['phone']])->where('id','<>',$id)->find()){
				return error(lang('tip')['re_phone']);
				exit;
			}
			if($id){
				db("user")->where(['id' => $id])->update($data);
				$data['id'] = $id;
			}else{
				$data['type'] = 2;
				$data['regtime'] = time();
				$data['id'] = db("user")->insertGetId($data);
			}
		}else{
			$data = db("user")->where(['type' => '2','id' => $id])->find();
		}
        return view('',['data'  => $data]);
    }
	
	public function del()
    {
		$id = input("get.id")?input("get.id"):0;
		$page = input("get.page");
		$data = db("user")->where(['type' => '2'])->delete($id);
		redirect(url('/admin/seller?page='.$page));
		exit;
    }
}
